Skip to content

fix: Prevent turbo dev from hanging when daemon file watching fails#12091

Merged
anthonyshew merged 1 commit into
mainfrom
shew/hanging-for-reason
Mar 2, 2026
Merged

fix: Prevent turbo dev from hanging when daemon file watching fails#12091
anthonyshew merged 1 commit into
mainfrom
shew/hanging-for-reason

Conversation

@anthonyshew
Copy link
Copy Markdown
Contributor

Summary

  • Add timeouts to prevent turbo dev from hanging indefinitely when the daemon's file watcher fails to initialize
  • Fix the daemon's package_changes gRPC stream to properly close when the underlying broadcast channel is closed
  • Improve error messages to help users diagnose and recover from file watching failures

Context

Users upgrading from 2.8.10 to 2.8.11/2.8.12 reported that turbo dev hangs after printing the version number, showing no output and no error. The root cause is a chain of missing timeouts and error handling in the daemon's file watching pipeline.

When the daemon's FileSystemWatcher fails to initialize (e.g. FSEvents on macOS doesn't deliver events, cookie directory permission issues, or a stale daemon from a previous version), several things go wrong:

  1. The PackageChangesWatcher subscriber waits forever on OptionalWatch::get() for file events that will never arrive
  2. The daemon's gRPC package_changes stream handler loops on RecvError::Closed instead of breaking, producing infinite error events
  3. The client's WatchClient::start() blocks on events.next().await with no timeout, appearing frozen

Changes

crates/turborepo-lib/src/run/watch.rs — Add a 10-second timeout when the client waits for the first event from the daemon's package_changes stream. Fails with an actionable error message instead of hanging.

crates/turborepo-lib/src/package_changes_watcher.rs — Add a 5-second timeout to the subscriber's wait for file events to become ready. Previously waited indefinitely.

crates/turborepo-daemon/src/server.rs — Fix the package_changes gRPC handler to distinguish RecvError::Closed from RecvError::Lagged. On Closed, it now sends one error event and breaks out of the loop instead of spinning.

crates/turborepo-filewatch/src/lib.rs — Upgrade file watcher initialization failure logs from warn! to error! with guidance to run turbo daemon clean.

Testing

Added 3 new tests:

  • optional_watch::test::get_returns_error_when_sender_dropped — Verifies error propagation when the sender drops without sending
  • optional_watch::test::get_with_timeout_returns_elapsed_when_no_value — Verifies timeout behavior for the pattern used in the fix
  • server::test::package_changes_stream_closes_on_sender_drop — Reproduces the exact bug: broadcast sender drops, verifies the forwarding loop sends an error event and terminates instead of spinning

@anthonyshew anthonyshew requested a review from a team as a code owner March 2, 2026 03:49
@anthonyshew anthonyshew requested review from tknickman and removed request for a team March 2, 2026 03:49
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Mar 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
examples-basic-web Ready Ready Preview, Comment, Open in v0 Mar 2, 2026 3:49am
examples-designsystem-docs Ready Ready Preview, Comment, Open in v0 Mar 2, 2026 3:49am
examples-gatsby-web Ready Ready Preview, Comment, Open in v0 Mar 2, 2026 3:49am
examples-kitchensink-blog Building Building Preview, Comment, Open in v0 Mar 2, 2026 3:49am
examples-nonmonorepo Ready Ready Preview, Comment, Open in v0 Mar 2, 2026 3:49am
examples-svelte-web Ready Ready Preview, Comment, Open in v0 Mar 2, 2026 3:49am
examples-tailwind-web Ready Ready Preview, Comment, Open in v0 Mar 2, 2026 3:49am
examples-vite-web Ready Ready Preview, Comment, Open in v0 Mar 2, 2026 3:49am
turbo-site Building Building Preview, Comment, Open in v0 Mar 2, 2026 3:49am
turborepo-agents Building Building Preview, Comment, Open in v0 Mar 2, 2026 3:49am
turborepo-test-coverage Building Building Preview, Comment, Open in v0 Mar 2, 2026 3:49am

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 2, 2026

Coverage Report

Metric Coverage
Lines 83.79%
Functions 79.72%
Branches 0.00%

View full report

@anthonyshew anthonyshew enabled auto-merge (squash) March 2, 2026 04:01
@anthonyshew anthonyshew merged commit b0d2f62 into main Mar 2, 2026
55 checks passed
@anthonyshew anthonyshew deleted the shew/hanging-for-reason branch March 2, 2026 04:08
github-actions Bot added a commit that referenced this pull request Mar 2, 2026
## Release v2.8.13-canary.9

Versioned docs: https://v2-8-13-canary-9.turborepo.dev

### Changes

- fix: Treat `npm: alias` dependencies as external, not workspace
references (#12061) (`b179cb8`)
- test: Port 18 more prysk tests to Rust (other/ +
lockfile-aware-caching/) (#12062) (`7887af2`)
- release(turborepo): 2.8.13-canary.8 (#12063) (`2a5522a`)
- fix: Preserve file: protocol entries in pruned yarn v1 lockfile
(#12064) (`ae5c1a1`)
- perf: Use stack-allocated OidHash in FileHashes and skip expanded
hashes on normal runs (#12065) (`677b248`)
- test: Port all 8 find-turbo prysk tests to Rust (#12066) (`f827fca`)
- fix: Support pnpm per-workspace lockfiles in turbo prune (#12067)
(`23d047d`)
- test: Port final 2 prysk tests to Rust (100% complete) (#12068)
(`6d7e057`)
- fix: Resolve Berry prune failure when resolutions contain patch
overrides (#12069) (`6fe3c5e`)
- test: Add lockfile fixture for yarn berry resolution pruning (issue
#2791) (#12071) (`6cc1654`)
- chore: Remove prysk test framework entirely (#12070) (`ed2d05a`)
- refactor: Clean up test infrastructure and eliminate duplication
(#12072) (`338911d`)
- fix: Retain injected workspace package entries during pnpm lockfile
pruning (#12073) (`acbe869`)
- ci: Exclude turborepo-lsp and turborepo-schema-gen from test builds
(#12075) (`4ce12e2`)
- refactor: Clean up test infrastructure + improve test quality (#12074)
(`4571f2b`)
- ci: Remove redundant cargo build from coverage job (#12077)
(`3c9bbe2`)
- perf: Speed up lockfile test suite (#12078) (`20024df`)
- ci: Remove integration test serialization (#12079) (`24d7c02`)
- fix: Preserve `file:` and `link:` protocol entries in pruned bun
lockfile (#12076) (`2635d9a`)
- fix: Stop running unnecessary npm install in engines tests (#12081)
(`24e4905`)
- test: Add lockfile fixture for pnpm v9 injected workspace deps (issue
#8243) (#12082) (`4d4929b`)
- fix: Filter orphaned Yarn packageExtensions entries during lockfile
pruning (#12084) (`68eb223`)
- fix: Align experimentalObservability on object maps rather than arrays
(#12089) (`9b9d1e4`)
- examples: Upgrade with-react-native-web example to use latest versions
(#12085) (`980ca43`)
- fix: duplicate /signup? in Vercel URL (#12088) (`e865b51`)
- ci: Deduplicate Rust test compilation with nextest archive (#12083)
(`962cf39`)
- fix: Prevent yarn integration tests from hanging on corepack prompts
(#12090) (`29b0da7`)
- fix: Prevent turbo dev from hanging when daemon file watching fails
(#12091) (`b0d2f62`)
- ci: Skip pnpm install for Rust test jobs (#12092) (`ebd137f`)
- perf: Optimize npm lockfile parser (#12093) (`e4b4a66`)
- chore: Trim unused dependency features for faster compilation (#12094)
(`03b79e0`)
- fix: Prevent lockfile-aware yarn test from hanging on corepack
downloads (#12095) (`bf516e4`)
- fix: Exclude turborepo-repository from JS smoke test in release
workflow (#12097) (`fecc400`)

---------

Co-authored-by: Turbobot <turbobot@vercel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant